<template>
  <div>
      <!-- 顶部滑动菜单 -->
    <div id="slider" class="mui-slider">
        <div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
            <div class="mui-scroll">
                <a v-for="item in cates" :key="item.id" :class="['mui-control-item', item.id == 0 ?' mui-active': '']"  href="#item1mobile" @tap="getImagelist(item.id)">
                    {{item.title}}
                </a>
            </div>
        </div>
    </div>

    <!-- 图片列表区域 -->
    <ul class="photo-list">
        <router-link :to="'/home/photo/photoinfo/'+item.id" tag="li" v-for="item in list" :key="item.id">
            <img v-lazy="item.img_url">
            <div class="info">
                <h1 class="title">{{item.title}}</h1>
                <div class="info-body">{{item.zhaiyao}}</div>
            </div>
        </router-link>
    </ul>
</div>
</template>
<script>
//导入mui.js使用动画效果
import mui from '../../lib/mui/js/mui.min.js'

export default{
data(){
    return {
        cates:[],
        list:[]
    }
},
created(){
    this.getAllcategory()
    this.getImagelist(0)
},
mounted(){
    mui('.mui-scroll-wrapper').scroll({
	deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
    })
},
methods:{
    getAllcategory(){
        this.$http.get('api/getimgcategory').then(result=>{
            if(result.body.status===0){
                result.body.message.unshift({title:'全部',id:0})
                this.cates = result.body.message
            }
        })
    },
    getImagelist(cateid){
        this.$http.get('api/getimages/'+cateid).then(result=>{
            if(result.body.status===0){
                this.list = result.body.message
            }
        })
    }
}
}
</script>
<style lang='scss' scoped>
* {//解决滑动样式控制面板弹出的警告
    touch-action: pan-y;
}
.photo-list{
    margin: 0;
    padding: 10px;
    list-style: none;
    img{
        width: 100%;
    }
    li{
        position: relative;
        box-shadow: 0 0 6px #666;
        img[lazy=loading]{
            width: 40px;
            height: 300px;
            margin: auto;
        }
        .info{
            position: absolute;
            bottom: 0;
            background-color: rgba(216,216,216,0.6);
            .title{
                font-size: 14px;
            }
            .info-body{
                font-size: 12px;
            }
        }
    }
}


</style>
